import http from '@/http/http'
import {
    AddRoleModel,
    AssignSaveParam,
    RoleParam,
    RoleListParam
} from './RoleModel'
enum Api {
    getRoleList = '/api/v1/role/getList',
    addAndEditAndDel = '/api/v1/role/role',
    assignTree = '/api/v1/role/getAssignPermissionTree',
    assignSave = '/api/v1/role/roleAssignSave',
    assignApiTree = '/api/v1/role/getAssignPermissionApi'
}

// 角色列表
export const getRoleListApi = async (param: RoleListParam) => {
    return await http.get(Api.getRoleList, param)
}
// 新增角色
export const addRoleApi = async (param: AddRoleModel) => {
    return await http.post(Api.addAndEditAndDel, param)
}
// 编辑角色
export const editRoleApi = async (param: AddRoleModel) => {
    return await http.put(Api.addAndEditAndDel, param)
}
// 删除角色
export const delRoleApi = async (param: RoleParam) => {
    return await http.delete(Api.addAndEditAndDel, param)
}
// 分配权限树的数据
export const assignTreeApi = async (param: RoleParam) => {
    return await http.getRestApi(Api.assignTree, param)
}
// 分配权限树的数据
export const assignApiTreeApi = async (param: RoleParam) => {
    return await http.getRestApi(Api.assignApiTree, param)
}
// 分配权限保存
export const assignSaveApi = async (param: AssignSaveParam) => {
    return await http.post(Api.assignSave, param)
}
